<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.cyys.com/cyystaglib" prefix="cyys"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
  	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" method="post" id="basicform" >
			<input name="id" value="${org.id }" type="hidden" id="id">
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">上级机构</label>
				<div class="layui-input-inline">
					<input type="hidden" id="parentId" name="parentId" value="${org.parentId}" >
		     		<input type="text" id="parentName" class="layui-input" readonly="readonly" value="${org.parentName}" lay-verify="required"
		     			placeholder="点击选择上级机构" onclick="selectOrg()">
				</div>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="selectOrg()">点击选择</button>
				</div>
			</div>
			
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">机构名称</label>
				<div class="layui-input-inline">
					<input name="name" placeholder="请输入机构名称" id="name"
						class="layui-input" lay-verify="required" value="${org.name }" maxlength="100">
				</div>
			</div>

            <%--<div class="layui-form-item layui-form" id="geographical" lay-filter="geographical">
                <label class="layui-form-label layui-form-required">所属区域</label>
                <div class="layui-input-inline">
                    <select id="province" name="province" lay-filter="distpicker" data-province="${org.province }">
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select id="city" name="city" lay-filter="distpicker" data-city="${org.city }">
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select id="district" name="county" lay-filter="distpicker" data-district="${org.county }">
                    </select>
                </div>
            </div>--%>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">机构类型</label>
				<div class="layui-input-inline">
					<select id="type" name="type" lay-verify="required">
						<cyys:dict name="ORG_TYPE" dv="${org.type}"/>
					</select>
				</div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">排序</label>
				<div class="layui-input-inline">
					<input name=sort placeholder="请输入排序" lay-verify="required|number"
						class="layui-input" value="${org.sort }" maxlength="100">
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
		</div>
	</div>
</div>
	<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/coreTree-2.0.0.js?v=${FILE_VERSION}"></script>

	<%--<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/distpicke/distpicker.data.js?v=${fileDataVersion}"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/distpicke/distpicker.js?v=${fileDataVersion}"></script>
	--%>
	<script>
		layui.use(['form'], function() {
			var form = layui.form;

            /*form.on('select(distpicker)', function(data) {
                $(data.elem).trigger("change");
                form.render('select','geographical');
            });*/

			form.on('submit(sub)', function(data){
				return saveOrUpdate($("#id").val(),"/sys/org",data);
			});
		});

        <%--这个代码位置很微妙，放其他地方异常，只能放在这，layui.use里不行，封装成函数放到js里再此处调用函数也不行，不知道为啥
        $("#geographical").distpicker({--%>
        <%--    placeholder : true,--%>
        <%--    autoSelect : false,--%>
		<%--	systemProvince:'${SYSTEM_PROVINCE_CODE}'--%>
        <%--});--%>
		
		function closed(){
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
			parent.layer.close(index);//关闭弹出的子页面窗口
		}
		
		function selectOrg(){
			var url  = getContextPath() +  "/sys/org/setOrg?queryTop=true";
			layer.open({
			  title : "选择机构",
			  type: 2,
			  area: ['500px', '90%'],
			  anim: 2,
			  content: [url, 'yes']
			});
		}
		
		function setOrg(id,name){
			$("#parentId").val(id);
			$("#parentName").val(name);
			layer.closeAll();
		}
	</script>
</body>
</html>